[qemu] Remove -vnclisten option since the same functionality is now
authorChristian Limpach <Christian.Limpach@xensource.com>
Thu, 10 May 2007 14:17:20 +0000 (15:17 +0100)
committerChristian Limpach <Christian.Limpach@xensource.com>
Thu, 10 May 2007 14:17:20 +0000 (15:17 +0100)
available using the -vnc option.

Signed-off-by: Christian Limpach <Christian.Limpach@xensource.com>
tools/ioemu/vl.c
tools/ioemu/vl.h
tools/ioemu/vnc.c

index e71001262cb91656ea2716ed1d3f298d3d3a63ea..af9067eb51588c1f049dbbcecf3005c5ba10c061 100644 (file)
@@ -133,7 +133,6 @@ static DisplayState display_state;
 int nographic;
 int vncviewer;
 int vncunused;
-struct sockaddr_in vnclisten_addr;
 const char* keyboard_layout = NULL;
 int64_t ticks_per_sec;
 char *boot_device = NULL;
@@ -3020,22 +3019,10 @@ fail:
     return -1;
 }
 
-int parse_host(struct sockaddr_in *saddr, const char *buf)
-{
-    struct hostent *he;
-
-    if ((he = gethostbyname(buf)) != NULL) {
-        saddr->sin_addr = *(struct in_addr *)he->h_addr;
-    } else {
-        if (!inet_aton(buf, &saddr->sin_addr))
-            return -1;
-    }
-    return 0;
-}
-
 int parse_host_port(struct sockaddr_in *saddr, const char *str)
 {
     char buf[512];
+    struct hostent *he;
     const char *p, *r;
     int port;
 
@@ -3046,8 +3033,14 @@ int parse_host_port(struct sockaddr_in *saddr, const char *str)
     if (buf[0] == '\0') {
         saddr->sin_addr.s_addr = 0;
     } else {
-        if (parse_host(saddr, buf) == -1)
-            return -1;
+        if (isdigit(buf[0])) {
+            if (!inet_aton(buf, &saddr->sin_addr))
+                return -1;
+        } else {
+            if ((he = gethostbyname(buf)) == NULL)
+                return - 1;
+            saddr->sin_addr = *(struct in_addr *)he->h_addr;
+        }
     }
     port = strtol(p, (char **)&r, 0);
     if (r == p)
@@ -6333,7 +6326,6 @@ void help(void)
           "-vnc display    start a VNC server on display\n"
            "-vncviewer      start a vncviewer process for this domain\n"
            "-vncunused      bind the VNC server to an unused port\n"
-           "-vnclisten      bind the VNC server to this address\n"
            "-timeoffset     time offset (in seconds) from local time\n"
 #ifndef _WIN32
           "-daemonize      daemonize QEMU after initializing\n"
@@ -6435,7 +6427,6 @@ enum {
     QEMU_OPTION_acpi,
     QEMU_OPTION_vncviewer,
     QEMU_OPTION_vncunused,
-    QEMU_OPTION_vnclisten,
 };
 
 typedef struct QEMUOption {
@@ -6518,7 +6509,6 @@ const QEMUOption qemu_options[] = {
     { "vnc", HAS_ARG, QEMU_OPTION_vnc },
     { "vncviewer", 0, QEMU_OPTION_vncviewer },
     { "vncunused", 0, QEMU_OPTION_vncunused },
-    { "vnclisten", HAS_ARG, QEMU_OPTION_vnclisten },
 
     /* temporary options */
     { "usb", 0, QEMU_OPTION_usb },
@@ -7086,8 +7076,6 @@ int main(int argc, char **argv)
 
     nb_nics = 0;
     /* default mac address of the first network interface */
-
-    memset(&vnclisten_addr.sin_addr, 0, sizeof(vnclisten_addr.sin_addr));
     
     /* init debug */
     sprintf(qemu_dm_logfilename, "/var/log/xen/qemu-dm.%ld.log", (long)getpid());
@@ -7492,9 +7480,6 @@ int main(int argc, char **argv)
             case QEMU_OPTION_vncunused:
                 vncunused++;
                 break;
-            case QEMU_OPTION_vnclisten:
-                parse_host(&vnclisten_addr, optarg);
-                break;
             }
         }
     }
@@ -7794,8 +7779,7 @@ int main(int argc, char **argv)
         dumb_display_init(ds);
     } else if (vnc_display != NULL || vncunused != 0) {
        int vnc_display_port;
-       vnc_display_port = vnc_display_init(ds, vnc_display, vncunused,
-                                           &vnclisten_addr);
+       vnc_display_port = vnc_display_init(ds, vnc_display, vncunused);
        if (vncviewer)
            vnc_start_viewer(vnc_display_port);
        xenstore_write_vncport(vnc_display_port);
index 4ca91e4dc77f612f93fc82cf56df5e91c0b6233a..1d8a38372865cd701131fe725838941eaa8633a1 100644 (file)
@@ -37,8 +37,6 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <sys/stat.h>
-#include <sys/socket.h>
-#include <sys/types.h>
 #include "xenctrl.h"
 #include "xs.h"
 #include <xen/hvm/e820.h>
@@ -956,7 +954,7 @@ void sdl_display_init(DisplayState *ds, int full_screen);
 void cocoa_display_init(DisplayState *ds, int full_screen);
 
 /* vnc.c */
-int vnc_display_init(DisplayState *ds, const char *display, int find_unused, struct sockaddr_in *iaddr);
+int vnc_display_init(DisplayState *ds, const char *display, int find_unused);
 void do_info_vnc(void);
 int vnc_start_viewer(int port);
 
index 83ea3a43fcb33d313e9abb51513ca490cf9d652e..46f1682e63f97a8e8fa38fb535f7084c32af6c61 100644 (file)
@@ -1393,9 +1393,10 @@ static void vnc_listen_read(void *opaque)
 
 extern int parse_host_port(struct sockaddr_in *saddr, const char *str);
 
-int vnc_display_init(DisplayState *ds, const char *arg, int find_unused, struct sockaddr_in *iaddr)
+int vnc_display_init(DisplayState *ds, const char *arg, int find_unused)
 {
     struct sockaddr *addr;
+    struct sockaddr_in iaddr;
 #ifndef _WIN32
     struct sockaddr_un uaddr;
 #endif
@@ -1456,8 +1457,8 @@ int vnc_display_init(DisplayState *ds, const char *arg, int find_unused, struct
     } else
 #endif
     {
-       addr = (struct sockaddr *)iaddr;
-       addrlen = sizeof(*iaddr);
+       addr = (struct sockaddr *)&iaddr;
+       addrlen = sizeof(iaddr);
 
        vs->lsock = socket(PF_INET, SOCK_STREAM, 0);
        if (vs->lsock == -1) {
@@ -1465,12 +1466,12 @@ int vnc_display_init(DisplayState *ds, const char *arg, int find_unused, struct
            exit(1);
        }
 
-       if (parse_host_port(iaddr, arg) < 0) {
+       if (parse_host_port(&iaddr, arg) < 0) {
            fprintf(stderr, "Could not parse VNC address\n");
            exit(1);
        }
            
-       iaddr->sin_port = htons(ntohs(iaddr->sin_port) + 5900);
+       iaddr.sin_port = htons(ntohs(iaddr.sin_port) + 5900);
 
        reuse_addr = 1;
        ret = setsockopt(vs->lsock, SOL_SOCKET, SO_REUSEADDR,
@@ -1483,7 +1484,7 @@ int vnc_display_init(DisplayState *ds, const char *arg, int find_unused, struct
 
     while (bind(vs->lsock, addr, addrlen) == -1) {
        if (find_unused && errno == EADDRINUSE) {
-           iaddr->sin_port = htons(ntohs(iaddr->sin_port) + 1);
+           iaddr.sin_port = htons(ntohs(iaddr.sin_port) + 1);
            continue;
        }
        fprintf(stderr, "bind() failed\n");
@@ -1500,7 +1501,7 @@ int vnc_display_init(DisplayState *ds, const char *arg, int find_unused, struct
        exit(1);
     }
 
-    return ntohs(iaddr->sin_port);
+    return ntohs(iaddr.sin_port);
 }
 
 int vnc_start_viewer(int port)